import json
import datetime
from time import sleep
from bs4 import BeautifulSoup

import httpx

client = httpx.Client(http2=True, timeout=10000)
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
    'X-Requested-With': 'XMLHttpRequest',
}


def getTable():
    url = "https://www.aixinzhijie.com/flash";

    response = client.get(url, headers=headers)
    if response.status_code == 200:
        html_content = response.content
        # 使用BeautifulSoup解析网页内容
        soup = BeautifulSoup(html_content, 'html.parser')
        # 获取新闻列表
        items = soup.find_all('div', class_='list-item--wrap list-item--lg')
        for item in items:
            d = item.find('div', class_='flash-item')
            title = d.find('h6').find('a').text
            if title.find('要闻一览') > 0:
                time = d.find('p', class_='flash-time').find('span').text
                href = d.find('p', class_='flash-time').find('a').get('href') if d.find('p',
                                                                                        class_='flash-time').find(
                    'a') is not None else None
                content = d.find('div', class_='ne-render-content')
                print(title, time, href, content)


if __name__ == '__main__':
    getTable()
